package com.manong.bookstore.admin.service.impl;

import com.alibaba.nacos.client.utils.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manong.common.utils.PageUtils;
import com.manong.common.utils.Query;

import com.manong.bookstore.admin.dao.ClassifyDao;
import com.manong.bookstore.admin.entity.ClassifyEntity;
import com.manong.bookstore.admin.service.ClassifyService;


@Service("classifyService")
public class ClassifyServiceImpl extends ServiceImpl<ClassifyDao, ClassifyEntity> implements ClassifyService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //1、获取key
        String key = (String) params.get("key");
        QueryWrapper<ClassifyEntity> queryWrapper = new QueryWrapper<>();

        if(!StringUtils.isEmpty(key)){
            queryWrapper.eq("classify_id",key).or().like("classify_desc",key);
        }

        IPage<ClassifyEntity> page = this.page(
                new Query<ClassifyEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}